﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Chapter14.Code08
{
    using System.Runtime.CompilerServices;

    public class Demo
    {
        public static void Begin()
        {
            DisplayCallerInformation();
            Action callerDelegate = new Action(() => DisplayCallerInformation());
            callerDelegate();
            CallerHelper(callerDelegate);
            Caller();
            DisplayCallerInformation(3, "BOb", @"C:\Temp\NotRealCode.cs");
            Console.ReadLine();
        }

        private static void DisplayCallerInformation([CallerLineNumber]int callerLineNumber = 0, [CallerMemberName]string callerMemberName = null, [CallerFilePath]string callerFilePath = null)
        {
            Console.WriteLine(string.Format("Method called form line {0} of member {1} in file {2}.", callerLineNumber, callerMemberName, callerFilePath));
        }

        private static void Caller()
        {
            DisplayCallerInformation();
        }

        private static void CallerHelper(Action callToMake)
        {
            callToMake();
        }
    }
}
